const mongoose = require('mongoose');

// 构建评论模型
const Schema = mongoose.Schema;
const commentsSchema = new Schema({
	content: {
		type: String,
		require: true
	},
	auth: { // 评论者
		type: Schema.Types.ObjectId,
		ref: 'user'
	},
	article: { // 所属文章
		type: Schema.Types.ObjectId,
		ref: 'article'
	},
	children: [
		{
			type: Schema.Types.ObjectId,
			ref: 'comments_children'
		}
	],
	createDate: {
		type: Date,
		default: Date.now
	},
	upDate: {
		type: Date,
		default: Date.now
	},
	delete: {
		type: Boolean,
		default: false
	}
});

module.exports = mongoose.model('comments', commentsSchema);
